'use client'

import {Radio, RadioChangeEvent, Space} from "antd";
import React from "react";
import {QuestionBankItemVo} from "@/types";

function RadioTpl({ items, onChange }: {items: QuestionBankItemVo[], onChange: any}) {

  const details = items.map((i, index) => {
    return (
      <Radio key={index} value={i.optionId}>{ i.optionValue }</Radio>
    )
  })

  const onChangeRadio = (e: RadioChangeEvent) => {
    onChange(e.target.value);
  }

  return (
    <Radio.Group onChange={onChangeRadio}>
      <Space direction="vertical">
        {details}
      </Space>
    </Radio.Group>
  )
}

export default RadioTpl
